/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.chl.vrangogym.web.admin;

import edu.chl.vrangogym.persistence.entities.User;
import edu.chl.vrangogym.persistence.entities.enums.Permissions;
import edu.chl.vrangogym.persistence.impl.UserFacade;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.faces.bean.ManagedBean;

/**
 * 
 * @author Anders
 */
@ManagedBean(name = "AdminUsers")
@RequestScoped
public class AdminUsersBackingBean implements Serializable {
    @EJB
    private UserFacade userFacade;

    private List<User> users;
    private HashMap<String, Permissions> permissions;

    public AdminUsersBackingBean() {
    }
    
    @PostConstruct
    public void init() {
        updateUsers();
        permissions = new HashMap<String, Permissions>();
        for(Permissions p : Permissions.values()) {
            permissions.put(p.toString(), p);
        }
    }
    
    public void updateUsers() {
        users = (List<User>) userFacade.findAll();
    }

    public List<User> getUsers() {
        return users;
    }

    public void setUsers(List<User> users) {
        this.users = users;
    }

    public HashMap<String, Permissions> getPermissions() {
        return permissions;
    }

    public void setPermissions(HashMap<String, Permissions> permissions) {
        this.permissions = permissions;
    }
    
}
